package com.frank.oj.service.admin.system.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.frank.model.entity.user.SystemLog;
import com.frank.oj.mapper.SystemLogMapper;
import com.frank.oj.service.admin.system.SystemLogService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
* @author frank
* @description 针对表【system_log】的数据库操作Service实现
* @createDate 2024-04-13 22:20:19
*/
@Service
public class SystemLogServiceImpl extends ServiceImpl<SystemLogMapper, SystemLog>
    implements SystemLogService{
    @Resource
    private SystemLogMapper systemLogMapper;

    @Override
    public IPage<SystemLog> getUserSystemLogs(Integer currentPage, Integer limit, String userName) {
        Page<SystemLog> page = new Page<>(currentPage, limit);
        LambdaQueryWrapper<SystemLog> queryWrapper = new LambdaQueryWrapper<>();
        if (!StringUtils.isEmpty(userName)){
            queryWrapper.like(SystemLog::getUsername,userName);
        }
        queryWrapper.orderByDesc(SystemLog::getGmtCreate);
         return systemLogMapper.selectPage(page,queryWrapper);
    }
}




